package net.zjitc.login.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author Administrator
 * @Date 2020/5/29 10:20
 * 继承；重写请求方法；注解配置（别名）
 **/
@WebServlet("/successServlet")
public class SuccessServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        /* 1、获取域对象内容
           2、页面上显示：欢迎您,张三
              1）设置响应编码
              2）设置响应内容/消息
        *  */
        String user = (String) req.getAttribute("user");
        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().write("欢迎您，"+user);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }
}
